﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="TwitterPoll_WebRole._Default" %>

<%@ Import Namespace="System.Linq" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Tweetpoll</title>
    <meta http-equiv="X-UA-Compatible" content="IE=7" />
    <!--The next line of code will refresh the page every X seconds-->
    <meta http-equiv="refresh" content="30" />
    <!--[if IE]><script language="javascript" type="text/javascript" src="../script/excanvas.pack.js"></script><![endif]-->

    <script language="javascript" type="text/javascript" src="/script/jquery.js"></script>

    <script language="javascript" type="text/javascript" src="/script/jquery.flot.js"></script>

</head>
<body>
<h1><i>TweetPoll</i></h1>
<i><p>This page will refresh periodically!</p></i>
    <p>
        This is a website intended to demo the capabilities of Windows Azure storage, web
        roles and worker roles. There is an associated blog post at <a href="http://blogs.conchango.com/jamiethomson/archive/2009/05/06/tweetpoll-my-first-windows-azure-application-is-live.aspx">
            http://blogs.conchango.com/jamiethomson/archive/2009/05/06/tweetpoll-my-first-windows-azure-application-is-live.aspx</a>
        which explains all and which, if you are reading this, you have probably already
        read immediately prior to coming here but if not let me tell you what the graph
        below represents.</p>
    <p>
        An Azure worker role is responsible for polling Twitter's public timeline (<a href="http://twitter.com/statuses/public_timeline.atom">http://twitter.com/statuses/public_timeline.atom</a>)
        periodically and placing each returned tweet onto an Azure queue. Another thread
        in that worker role continually picks off a message from the head of the queue,
        determines the length of the tweet and increments a counter stored in an Azure table.
        There is a counter for each possible tweet length (1 to 140)</p>
    <p>
        The graph below is generated inside an Azure web role by querying the aforementioned
        Azure table and thus visualising all of the counters. It shows the distribution of lengths of tweets based on a sample set</p>
    <hr />
    <h3>Graph to show distribution of tweet lengths</h3>
    <div id="placeholder" style="width: 900px; height: 300px;">
    </div>
    <div>
        <i>I used <a href="http://code.google.com/p/flot/">flot</a> to generate the graph!!</i>
    </div>
    <hr />
    <form id="form1" runat="server">
    <div>
    <h3>Sample Set</h3>
        <asp:Label runat="server" BorderStyle="None" Text="Size of sample set = " /><asp:TextBox
            runat="server" ID="txtTotalTweets" BorderStyle="None" /><asp:Label ID="Label1" runat="server" BorderStyle="None" Text="(and growing)" />
    </div>
    <p />
    <p />
    <hr />
    <div>
    <h3>Current Queue Contents</h3>
        <p>
            The table below shows some tweets that currently reside on the Azure queue. This
            is done by issuing a GET request to http://myaccount.queue.core.windows.net/myqueue/messages?peekonly=true
            (<a href="http://msdn.microsoft.com/en-us/library/dd179472.aspx"><i>Docs</i></a>)
        </p>
        <asp:DataGrid runat="server" ID="CurrentTweetsOnQueue">
        </asp:DataGrid>
    </div>
    <hr />
    <h3>Page Load Count</h3>
        <asp:Label ID="Label2" runat="server" BorderStyle="None" Text="This page has been accessed " /><asp:TextBox
            runat="server" ID="txtPageLoadCount" BorderStyle="None" /><asp:Label ID="Label3" runat="server" BorderStyle="None" Text=" times" />
    </form>
</body>
</html>
